package cn.njyd.corejava.thread.myday01;

import java.util.TreeMap;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

public class CallableDemo02 {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        FutureTask<String> futureTask = new FutureTask<>(()->{
            System.out.println(Thread.currentThread().getName()+" come in");
            Thread.sleep(1000);
            System.out.println(Thread.currentThread().getName()+" over");

            return "hello";
        });
        Thread t1 = new Thread(futureTask);
        t1.start();

        System.out.println(Thread.currentThread().getName()+"处理自己的事情");
        System.out.println(futureTask.get());

    }
}
